package thread;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;


/**
 * @author DBX
 * @effect 定时任务
 * @date 2021/09/10/20:05
 */
public class TimeTest {
    public static void main(String[] args) throws ParseException {

        Timer time = new Timer();
        SimpleDateFormat simpleDateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date first = simpleDateFormat.parse("2021-9-10 20:18:00");
        time.schedule(new LogTimerTask(),first,10000);
    }
}
class LogTimerTask extends TimerTask {
    @Override
    public void run() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String strTime = sdf.format(new Date());
        System.out.println(strTime+"--->完成备份");
    }
}
